Component({
    properties: {

    },
    data: {
        selected:0,
        tabList:[
            {
                "pagePath": "pages/question-index/question-index",
                "text": "问题",
            },
            {
                "pagePath": "pages/recommend/recommend",
                "text": "推荐"
            },
            {
                "pagePath": "pages/question-publish/question-publish",
                "text": "发布"
            },
            {
                "pagePath": "pages/friend-circle/friend-circle",
                "text": "点滴"
            },
            {
                "pagePath": "pages/me/me",
                "text": "我的"
            }
        ]
    },
    methods: {
        switchTab(e){
            console.log(this.data)
            let key = Number(e.currentTarget.dataset.index);
            let tabList = this.data.tabList;
            let selected = this.data.selected;

            if(selected !== key){
                this.setData({
                    selected:key
                });
                wx.switchTab({
                    url: `/${tabList[key].pagePath}`,
                })
            }
        }
    }
})


